#include "annotation.h"

TextNoteAnnotation::TextNoteAnnotation(QByteArray docHash, int id, int pageNumber) :
	docHash(docHash), id(id), pageNumber(pageNumber)
{
	maximized = true;
	maximumSize = QSize(240, 200);
}

QByteArray TextNoteAnnotation::getDocHash()
{
	return docHash;
}

int TextNoteAnnotation::getId()
{
	return id;
}

int TextNoteAnnotation::getPageNumber()
{
	return pageNumber;
}

QString TextNoteAnnotation::getTitle()
{
	return title;
}

void TextNoteAnnotation::setTitle(QString title)
{
	this->title = title;
}

QString TextNoteAnnotation::getRichText()
{
	return richText;
}

void TextNoteAnnotation::setRichText(QString text)
{
	this->richText = text;
}

QColor TextNoteAnnotation::getColor()
{
	return color;
}

void TextNoteAnnotation::setColor(QColor color)
{
	this->color = color;
}

QPointF TextNoteAnnotation::getPos()
{
	return pos;
}

void TextNoteAnnotation::setPos(QPointF pos)
{
	this->pos = pos;
}

bool TextNoteAnnotation::getMaximized()
{
	return maximized;
}

void TextNoteAnnotation::setMaximized(bool maximized)
{
	this->maximized = maximized;
}

QSize TextNoteAnnotation::getMaximumSize()
{
	return maximumSize;
}

void TextNoteAnnotation::setMaximumSize(QSize maximumSize)
{
	this->maximumSize = maximumSize;
}

QDataStream& operator<<(QDataStream& out, const TextNoteAnnotation& n)
{
	qint32 ver = 2;
	out << ver;
	out << n.docHash;
	out << n.id;
	out << n.pageNumber;
	out << n.title;
	out << n.richText;
	out << n.color;
	out << n.pos;
	out << n.maximized;
	out << n.maximumSize;
	return out;
}

QDataStream& operator>>(QDataStream& in, TextNoteAnnotation& n)
{
	qint32 ver;
	in >> ver;
	in >> n.docHash;
	in >> n.id;
	in >> n.pageNumber;
	in >> n.title;
	in >> n.richText;
	in >> n.color;
	in >> n.pos;
	in >> n.maximized;
	if (ver >= 2) {
		in >> n.maximumSize;
	}
	return in;
}


HighlightAnnotation::HighlightAnnotation(QByteArray docHash, int pageNumber, QRectF bbox, QColor color) :
	docHash(docHash), pageNumber(pageNumber), bbox(bbox), color(color)
{
}

QByteArray HighlightAnnotation::getDocHash()
{
	return docHash;
}

int HighlightAnnotation::getPageNumber()
{
	return pageNumber;
}

QRectF HighlightAnnotation::getBBox()
{
	return bbox;
}

QColor HighlightAnnotation::getColor()
{
	return color;
}

void HighlightAnnotation::setColor(QColor color)
{
	this->color = color;
}

QDataStream& operator<<(QDataStream& out, const HighlightAnnotation& n)
{
	qint32 ver = 2;
	out << ver;
	out << n.docHash;
	out << n.pageNumber;
	out << n.bbox;
	out << n.color;
	return out;
}

QDataStream& operator>>(QDataStream& in, HighlightAnnotation& n)
{
	qint32 ver;
	in >> ver;
	in >> n.docHash;
	in >> n.pageNumber;
	in >> n.bbox;
	in >> n.color;
	return in;
}
